package io.eleKing.boot.weather.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.*;
import io.eleKing.boot.system.entity.BaseEntity;

import java.util.Date;

/**
 * 
 *
 * @author eleKing
 * @since 2025-04-15
 */
@Data
@TableName("weather_hour_data")
@EqualsAndHashCode(callSuper = true)
public class WeatherHourData extends BaseEntity {

    private static final long serialVersionUID = 1L;
    protected Integer stationLevel;
    private String district;
    private String stationId;
    private Integer regionStation;
    /**
     * 数据时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date dataTime;

    /**
     * 年
     */
    private Integer year;

    /**
     * 月
     */
    private Integer month;

    /**
     * 日
     */
    private Integer day;

    /**
     * 小时
     */
    private Integer hour;

    /**
     * 降雨量
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double pre;

    /**
     * 降雨量（1h）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double pre1h;

    /**
     * 降雨量（3h）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double pre3h;

    /**
     * 降雨量（6h）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double pre6h;

    /**
     * 降雨量（12h）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double pre12h;

    /**
     * 降雨量（24h）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double pre24h;

    /**
     * 两分钟平均风向
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windDirectAvg2mi;

    /**
     * 两分钟平均风速
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windSpeedAvg2mi;

    /**
     * 10分钟平均风向
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windDirectAvg10mi;

    /**
     * 10分钟平均风速
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windSpeedAvg10mi;

    /**
     * 最大风速
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windSpeedMax;

    /**
     * 最大风速的风向
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windDirectMax;

    /**
     * 最大风速出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date windSpeedMaxAppearTime;

    /**
     * 瞬时风速
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windSpeedInst;

    /**
     * 瞬时风向(角度)
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windDirectInst;

    /**
     * 极大风速的风向
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windDirectInstMax;
    public Double getWindDirectInstMax() {
        if (windDirectInstMax == null) return null;
        if (windDirectInstMax > 360) {
            windDirectInstMax = 0.0;
        }
        return windDirectInstMax;
    }

    @TableField(exist = false)
    private String windDirectInstMaxStr;

    /**
     * 极大风速
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double windSpeedInstMax;

    /**
     * 极大风速出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date windSpeedInstMaxAppearTime;

    /**
     * 气压（百帕）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double prs;

    /**
     * 海平面气压
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double prsSea;

    /**
     * 最高气压
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double prsMax;

    /**
     * 最高气压出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date prsMaxAppearTime;

    /**
     * 最低气压
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double prsMin;

    /**
     * 最低气压出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date prsMinAppearTime;

    /**
     * 3小时变压
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double prsChange3h;

    /**
     * 24小时变压
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double prsChange24h;

    /**
     * 相对湿度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Integer rhu;

    /**
     * 最小相对湿度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Integer rhuMin;

    /**
     * 最小相对湿度出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date rhuMinAppearTime;

    /**
     * 露点温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double dpt;

    /**
     * 能见度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Integer vis;

    /**
     * 能见度（最小）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Integer visMin;

    /**
     * 最小能见度出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date visMinAppearTime;

    /**
     * 平均温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double tem;

    /**
     * 最高温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double temMax;

    /**
     * 最高温度出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date temMaxAppearTime;

    /**
     * 最低温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double temMin;

    /**
     * 最低温度出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date temMinAppearTime;

    /**
     * 温度24H变温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double temChange24;

    /**
     * 温度24H最高
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double temMax24;

    /**
     * 温度24H最低
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double temMin24;

    /**
     * 地面温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem;

    /**
     * 最高地面温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTemMax;

    /**
     * 最高地面温度出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date gsTemMaxAppearTime;

    /**
     * 最低地面温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTemMin;

    /**
     * 最低地面温度出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date gsTemMinAppearTime;

    /**
     * 过去12小时地面最低温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTemMin12h;

    /**
     * 5cm地温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem5cm;

    /**
     * 10cm地温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem10cm;

    /**
     * 15cm地温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem15cm;

    /**
     * 20cm地温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem20cm;

    /**
     * 40cm地温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem40cm;

    /**
     * 80cm地温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem80cm;

    /**
     * 160cm地温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem160cm;

    /**
     * 320cm地温
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double gsTem320cm;

    /**
     * 草面(雪面)温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double lgsTem;

    /**
     * 最高草面(雪面)温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double lgsTemMax;

    /**
     * 最高草面(雪面)温度出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date lgsTemMaxAppearTime;

    /**
     * 最低草面(雪面)温度
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double lgsTemMin;

    /**
     * 最低草面(雪面)温度出现时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date lgsTemMinAppearTime;

    /**
     * 积雪深度（厘米）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double snowDepth;

    /**
     * 雪压（千克/平方米）
     */
    @JsonSerialize(nullsUsing = NullSerializer.class)
    private Double snowPrs;

    private Integer weather;

    @TableField(exist = false)
    private String deviceStatus;

}